// 防抖
function debounce(fn, time) {
    let timer = null;
    return function (...args) {
        clearInterval(timer)
        setTimeout(() => {
            fn.apply(this, args)
        }, time)
    }
}

// 节流
function trottle(fn, time) {
    let timer = null;
    return function (...args) {
        if (!timer) {
            timer = setInterval(() => {
                fn.apply(this, args)
                timer = null;
            }, time);
        }
    }
}